namespace Hsenl.Network {
    public static class NetworkExtension {
        // 如果需要手动 flush writer的话, 把 service 里的 autoSend 设置为 false
        public static void FlushWriter(this Network self) {
            var channel = self.Service.GetChannel(0);
            switch (channel) {
                case KcpChannel kcpChannel: {
                    kcpChannel.FlushWriter();
                    break;
                }

                case TcpChannel tcpChannel: {
                    tcpChannel.FlushWriter();
                    break;
                }
            }
        }

        public static void FlushWriter(this Network self, long channelId) {
            var channel = self.Service.GetChannel(channelId);
            switch (channel) {
                case KcpChannel kcpChannel: {
                    kcpChannel.FlushWriter();
                    break;
                }

                case TcpChannel tcpChannel: {
                    tcpChannel.FlushWriter();
                    break;
                }
            }
        }
    }
}